/*console.time("jishi");

for(var i=0; i<10000; i++)
{
	for(var j=0; j<1000; j++){}
}

console.timeEnd("jishi");*/


function checkPalindrom(str)
{
	return str === str.split('').reverse().join('');
}

var str1 = 'abccba';
if(checkPalindrom(str1))
{
	console.log('right');
}else{
	console.log('wrong');
}


var arr1 = [11,1,34,64,34,76,213,34,2,11,67,45,76];
/*function filterArr(arr)
{
	//var k = arr.length;
	var data = [];
	for(var i=0; i<arr.length; i++)
	{
		for(var j=1; j<arr.length; j++)
		{
			data.push(arr[i]);
			if(arr[i] !== arr[j])
			{
				data.push(arr[j]);
				//k++;
			}

		}
		arr = data;
	}

	return data;
}*/

let unique = function(arr){
	let hashTable = {};
	let data = [];
	for(let i=0; i<arr.length; i++)
	{
		if(!hashTable[arr[i]])
		{
			hashTable[arr[i]] = true;
			data.push(arr[i]);
		}
	}
	return data;
}

console.log(unique(arr1));

let mostVar = function(str)
{
	if(str.length == 1)
	{
		return str;
	}

	var obj = {}
	var arr = str.split('');
	var charArr = [];
	var charArr2 = [];
	for(var i=0; i<arr.length; i++)
	{
		if(!obj[arr[i]])
		{
			
			charArr[arr[i]] += 1;

		}else{
			charArr[arr[i]] = 1;
		}
	}

	for(var j=0; j<charArr.length; j++)
	{
		
	}

}

var str2 = 'sdbfsjhgdfgjdwerjd';
function findMaxDuplicateChar(str) {  
  if(str.length == 1) {
    return str;
  }
  let charObj = {};
  for(let i=0;i<str.length;i++) {
    if(!charObj[str.charAt(i)]) {
      charObj[str.charAt(i)] = 1;
    }else{
      charObj[str.charAt(i)] += 1;
    }
  }
  let maxChar = '',
      maxValue = 1;
  for(var k in charObj) {
    if(charObj[k] >= maxValue) {
      maxChar = k;
      maxValue = charObj[k];
    }
  }
  return maxChar;
 
}

console.log(findMaxDuplicateChar(str2));